// UserActions 组件的业务逻辑函数
import {openLogin} from "../../common/openLogin";

export { render, renderLoggedOutState } from './html.js';
/**
 * 绑定事件监听器
 * @param {UserActions} component - 组件实例
 */
export function bindEvents(component) {
    window.addEventListener("load",function(){
        login(component);
        publish(component);
    })

}

/**
 * 登录按钮事件处理
 * @param  component {UserActions}- 组件实例
 */
export function login(component) {
    const btn = component.shadowRoot.querySelector("#login");


    btn?.addEventListener('click', (e) => {
        openLogin();
    });
}

/**
 * 登录按钮事件处理
 * @param component {any}- 组件实例
 * */
export function publish(component) {
    const btn = component.shadowRoot.querySelector("#publish");

    const app = document.getElementById('app');

    btn?.addEventListener('click', (e) => {
        const userPublishTarget = document.createElement('user-publish');

        app.appendChild(userPublishTarget);

        userPublishTarget.open();
    })

}